(function() {


    angular.module('BlurAdmin.pages.UserlistM')
        .controller('PhysicalRecordCtrl', PhysicalRecordCtrl);

    function PhysicalRecordCtrl($scope, tongxin, $http, $myconfig, $datepicker) {
        var user_id = tongxin.getUserInfo();
        console.log(typeof(user_id));
        console.log(~~(user_id));


        $scope.dat = {
            dat1: $datepicker.dataNew(),
            dat2: $datepicker.dataNew(),
        };
        $scope.dat.dat1.date_ = '';
        $scope.dat.dat2.date_ = '';
        var opt = $scope.search_opt = {
            user_id: ~~(user_id),
            limit: 10,
            page: 1,
            start_time: $scope.dat.dat1.date_, //开始时间
            end_time: $scope.dat.dat1.date_, //结束时间
            dev_name: '' //设备名字
        }

        $scope.Search = function() { //获取用户理疗记录统计数据
            var data1 = document.getElementById("dat9") ? document.getElementById("dat9").value : null;
            var data2 = document.getElementById("dat10") ? document.getElementById("dat10").value : null;
            opt.start_time = data1;
            opt.end_time = data2;

            $http.get($myconfig.api.users_users_physicallogs_count_b, { params: opt }).then(function(res) {
                console.log(res);
                $scope.bigTotalItems = res.data.data.count;
                Search_list();
            })
        }

        function Search_list() { //获取用户理疗记录统计数据

            $http.get($myconfig.api.users_users_physicallogs_list_b, { params: opt }).then(function(res) {
                if (res.data.success) {
                    for (var i = 0; i < res.data.data.length; i++) { //添加条数属性
                        res.data.data[i].num = (($scope.search_opt.page - 1) * $scope.search_opt.limit) + i + 1;
                    }
                    $scope.list_data = res.data.data;
                }
                console.log($scope.list_data);
            })
        }
        $scope.Search();

        //分页
        // $scope.bigTotalItems = 50;
        $scope.pageChanged = function(val) {
            console.log(val);
            var Page_num = val //选中的页面数
            $scope.search_opt.page = val;
            Search_list();
        };
        // getpar();


    }
})();